package com.zsp.coupon.feign.hystrix;

import com.zsp.coupon.feign.TemplateClient;
import com.zsp.coupon.vo.CommonResponse;
import com.zsp.coupon.vo.CouponTemplateSDK;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.*;

/**
 * 优惠卷Fegine 接口的熔断降级策略
 */
@Slf4j
@Component
public class TemplateClentHystrix implements TemplateClient {
    /**
     * 查找所有可用的优惠卷模板
     *
     * @return coupon-template网关设置的通用前缀+ template模板的controller
     */
    @Override
    public CommonResponse<List<CouponTemplateSDK>> findAllUsableTemplate() {
        log.error("[eureka-client-coupon-template] findAllUsableTemplate " +
                "request error");
            return  new CommonResponse<>(
                    -1,
                    "[eureka-client-coupon-template] request error",
                    Collections.emptyList()
                    );
    }

    /**
     * 获取到模板的ids到 CouponTemplateSDK
     * @return
     */
    @Override
    public CommonResponse<Map<Integer, CouponTemplateSDK>>
        findIds2TemplateSDK(Collection<Integer> ids) {
        log.error("[eureka-client-coupon-template] findAllUsableTemplate " +
                "request error");
            return new CommonResponse<>(
                    -1,
                    "[eureka-client-coupon-template] request error",
                   new HashMap<>()
            );
    }
}
